package com.test;

import com.ProvierAndCustoer.Bread;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;

/**
 * Created by 41579 on 2017/4/20.
 */
public class BlockqueueProductor implements Runnable{
    LinkedBlockingDeque<Bread> breadQueue;

    public BlockqueueProductor(LinkedBlockingDeque<Bread> breadQueue) {
        this.breadQueue = breadQueue;
    }

    @Override
    public void run() {
        while(true) {
            try {
                TimeUnit.SECONDS.sleep(3);
                breadQueue.push(new Bread());
                System.out.println(Thread.currentThread().getName() + " after product " + breadQueue.size());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
